<template>
  <div>
    <div class="form">
      <div class="search">
        <div class="date_picker">
          <el-input
            placeholder="商品名称"
            v-model="query.goodsName"
            class="search_info"
          >
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input>
          <el-input
            placeholder="订单编号"
            v-model="query.id"
            class="search_info"
          >
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input>
          <el-select
            v-model="query.orderStatus"
            placeholder="订单状态"
            class="search_info"
          >
            <el-option
              v-for="item in statusList"
              :key="item.key"
              :label="item.value"
              :value="item.key"
            ></el-option>
          </el-select>
          <!-- <el-input
            placeholder="订单状态"
            v-model="query.orderStatus"
            class="search_info"
          >
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input> -->
        </div>
        <div>
          <el-button @click="reset()" class="searchBtn">重置</el-button>
          <el-button type="primary" @click="getOrderList(1)" class="searchBtn"
            >搜索</el-button
          >
        </div>
      </div>
      <el-table
        class="listTable"
        v-loading="listLoading"
        :data="list"
        border
        fit
        highlight-current-row
        style="width: 100%"
      >
        <el-table-column label="序号" type="index" align="center">
        </el-table-column>
        <el-table-column label="用户编号" prop="userId" align="center">
        </el-table-column>
        <el-table-column label="用户名称" prop="userName" align="center">
        </el-table-column>
        <el-table-column label="订单编号" prop="id" align="center">
        </el-table-column>
        <el-table-column label="商品编号" prop="goodsId" align="center">
        </el-table-column>
        <el-table-column label="商品名称" prop="goodsName" align="center">
        </el-table-column>
        <el-table-column
          label="商品价格（元）"
          prop="goodsPrice"
          align="center"
        >
        </el-table-column>
        <el-table-column
          label="订单价格（元）"
          prop="orderPrice"
          align="center"
        >
        </el-table-column>
        <el-table-column label="订单状态" prop="orderStatus" align="center">
          <template slot-scope="{ row }">
            <span>{{ row.orderStatus | status }}</span>
          </template>
        </el-table-column>
        <el-table-column label="收货地址" prop="receiveAddress" align="center">
        </el-table-column>
        <el-table-column label="收货人" prop="receiver" align="center">
        </el-table-column>
        <el-table-column label="收货人号码" prop="phone" align="center">
        </el-table-column>
        <el-table-column label="订单创建时间" prop="createTime" align="center">
        </el-table-column>
      </el-table>
      <el-pagination
        :total="total"
        layout="total, sizes, prev, pager, next"
        :page-size="limit"
        :page-sizes="[10, 20, 50, 100]"
        @size-change="handleSizeChange"
        :current-page.sync="curPage"
        @current-change="getOrderList($event)"
        class="sortStyle"
      />
    </div>
  </div>
</template>

<script>
import {
  getOrderList,
  addGoods,
  goodDel,
  detailGoods,
  editGoods,
  extendList,
} from "@/api/system/user";
import { getToken } from "@/utils/auth";
import {} from "@/api/article";
export default {
  components: {},
  filters: {
    status: function(value) {
      switch (value) {
        case '1':
          return '下单未支付'
        case '2':
          return '下单已支付'
    
      }
    },
  },
  data() {
    return {
      statusList: [
        { key: 1, value: "下单未支付" },
        { key: 2, value: "下单已支付" },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
      token: {
        Authorization: getToken(),
      },
      form: {
        goodsCourseList: [],
      },
      query: {
        pageNum: 1,
        pageSize: 10
      },
      list: [],
      listLoading: false,
      total: 0,
      limit: 10,
      curPage: 1,
      listData: [],
      studentName: "",
      // studentClass: '',
      phonenumber: "",
      work: "",
      page: this.$route.query.page,
      personClass: "",
      classList: [],
      creatShow: false,
      imageUrl: "",
      imageName: "",
      editId: "",
      isPreview: true,
      // 表单校验
      rules: {
        titleType: [
          { required: true, message: "标题类型不能为空", trigger: "blur" },
        ],
        titleName: [
          { required: true, message: "标题内容不能为空", trigger: "blur" },
        ],
        subtitleName: [
          { required: true, message: "子标题内容不能为空", trigger: "blur" },
        ],
        titleExplain: [
          { required: true, message: "金额不能为空", trigger: "blur" },
        ],
        goodsCourseList: [
          { required: true, message: "课程表展示不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getOrderList(1);
    this.init();
  },
  mounted() {},
  methods: {
    init() {
      extendList().then((res) => {
        if (res.code == "200") {
          this.list = res.rows;
          this.total = res.total;
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    getOrderList(page) {
      this.query.pageNum = page
      getOrderList(this.query).then((res) => {
        if (res.code == "200") {
          this.list = res.rows;
          this.total = res.total;
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    handleSizeChange(val) {
      this.query.pageSize = val
      this.getOrderList(1)
    },
    reset() {
      this.query = {
        
      };
    },
  },
};
</script>
<style scoped>
.form {
  padding-left: 26px;
  padding-right: 24px;
  padding-top: 24px;
  background: #fff;
}
.search {
  display: flex;
  position: relative;
}
.search_info {
  width: 192px;
  height: 40px;
  margin-right: 16px;
}
.searchBtn {
  margin-left: 16px;
  height: 36px;
}
.sortStyle {
  height: 19px;
  float: right;
  /* right: 24px; */
  margin-top: 20px;
  margin-bottom: 30px;
}
.pos_right_btn {
  position: absolute;
  right: 0;
}
.opt_font {
  cursor: pointer;
  color: #2e82ff;
}
.detail_title {
  font-size: 16px;
  font-weight: 400;
  color: #212121;
  line-height: 22px;
}
.detail_title span {
  padding-left: 4px;
  background: #1e88e5;
  margin-right: 12px;
}
.row {
  display: flex;
  padding-bottom: 12px;
}
.detail_info {
  padding-top: 16px;
}
.info_left {
  display: flex;
}
.info_right {
  display: flex;
  padding-left: 202px;
}
.info_left_title {
  font-size: 14px;
  font-weight: 400;
  color: #616161;
  line-height: 20px;
  width: 112px;
  margin-right: 16px;
}
.info_left_content {
  font-size: 14px;
  font-weight: 400;
  color: #212121;
  line-height: 20px;
  width: 150px;
}
.pos_top {
  padding-top: 12px;
}
.detailTable {
  margin-top: 16px;
}
.opt_font {
  color: #1e88e5;
  cursor: pointer;
}
.page_pos {
  text-align: right;
  padding-top: 10px;
}
.backBtn {
  text-align: center;
  margin-top: 10px;
}
/deep/ .el-dialog {
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100% -30px);
  /* max-width: ; */
}
/deep/ .el-dialog .el-dialog__body {
  flex: 1;
  height: 700px;
  overflow-y: auto;
  padding-top: 0;
}
.tab {
  display: flex;
  position: absolute;
  right: 32px;
  top: 14px;
}
.tab_border {
  border: 1px solid #409eff;
  color: #409eff;
  padding: 10px 12px;
  font-size: 14px;
  margin-right: 16px;
}
.change {
  border: 1px solid #f56c6c;
  color: #f56c6c;
}
.listTable {
  margin-top: 17px;
}
.out {
  position: absolute;
  right: 0;
}
.row_inl {
  display: flex;
}
.sel_inp {
  width: 400px;
  height: 48px;
}
.sel_font {
  position: relative;
  top: 8px;
  width: 150px;
  text-align: right;
  padding-right: 24px;
}
.margin {
  margin-right: 16px;
}
.marginBot {
  margin-bottom: 10px;
}
.between {
  justify-content: space-between;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  /* text-align: center; */
  border: 1px dashed #000;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
